<HTML>
	<HEAD>
		<TITLE>Test Input</TITLE>
		<link href="style.css" rel="stylesheet" type="text/css" />
        
        <script src="lib/prototype-1.6.0.2.js"></script>

		<!-- box2djs -->
        <script src='js/box2d/common/b2Settings.js'></script>
        <script src='js/box2d/common/math/b2Vec2.js'></script>
        <script src='js/box2d/common/math/b2Mat22.js'></script>
        <script src='js/box2d/common/math/b2Math.js'></script>
        <script src='js/box2d/collision/b2AABB.js'></script>
        <script src='js/box2d/collision/b2Bound.js'></script>
        <script src='js/box2d/collision/b2BoundValues.js'></script>
        <script src='js/box2d/collision/b2Pair.js'></script>
        <script src='js/box2d/collision/b2PairCallback.js'></script>
        <script src='js/box2d/collision/b2BufferedPair.js'></script>
        <script src='js/box2d/collision/b2PairManager.js'></script>
        <script src='js/box2d/collision/b2BroadPhase.js'></script>
        <script src='js/box2d/collision/b2Collision.js'></script>
        <script src='js/box2d/collision/Features.js'></script>
        <script src='js/box2d/collision/b2ContactID.js'></script>
        <script src='js/box2d/collision/b2ContactPoint.js'></script>
        <script src='js/box2d/collision/b2Distance.js'></script>
        <script src='js/box2d/collision/b2Manifold.js'></script>
        <script src='js/box2d/collision/b2OBB.js'></script>
        <script src='js/box2d/collision/b2Proxy.js'></script>
        <script src='js/box2d/collision/ClipVertex.js'></script>
        <script src='js/box2d/collision/shapes/b2Shape.js'></script>
        <script src='js/box2d/collision/shapes/b2ShapeDef.js'></script>
        <script src='js/box2d/collision/shapes/b2BoxDef.js'></script>
        <script src='js/box2d/collision/shapes/b2CircleDef.js'></script>
        <script src='js/box2d/collision/shapes/b2CircleShape.js'></script>
        <script src='js/box2d/collision/shapes/b2MassData.js'></script>
        <script src='js/box2d/collision/shapes/b2PolyDef.js'></script>
        <script src='js/box2d/collision/shapes/b2PolyShape.js'></script>
        <script src='js/box2d/dynamics/b2Body.js'></script>
        <script src='js/box2d/dynamics/b2BodyDef.js'></script>
        <script src='js/box2d/dynamics/b2CollisionFilter.js'></script>
        <script src='js/box2d/dynamics/b2Island.js'></script>
        <script src='js/box2d/dynamics/b2TimeStep.js'></script>
        <script src='js/box2d/dynamics/contacts/b2ContactNode.js'></script>
        <script src='js/box2d/dynamics/contacts/b2Contact.js'></script>
        <script src='js/box2d/dynamics/contacts/b2ContactConstraint.js'></script>
        <script src='js/box2d/dynamics/contacts/b2ContactConstraintPoint.js'></script>
        <script src='js/box2d/dynamics/contacts/b2ContactRegister.js'></script>
        <script src='js/box2d/dynamics/contacts/b2ContactSolver.js'></script>
        <script src='js/box2d/dynamics/contacts/b2CircleContact.js'></script>
        <script src='js/box2d/dynamics/contacts/b2Conservative.js'></script>
        <script src='js/box2d/dynamics/contacts/b2NullContact.js'></script>
        <script src='js/box2d/dynamics/contacts/b2PolyAndCircleContact.js'></script>
        <script src='js/box2d/dynamics/contacts/b2PolyContact.js'></script>
        <script src='js/box2d/dynamics/b2ContactManager.js'></script>
        <script src='js/box2d/dynamics/b2World.js'></script>
        <script src='js/box2d/dynamics/b2WorldListener.js'></script>
        <script src='js/box2d/dynamics/joints/b2JointNode.js'></script>
        <script src='js/box2d/dynamics/joints/b2Joint.js'></script>
        <script src='js/box2d/dynamics/joints/b2JointDef.js'></script>
        <script src='js/box2d/dynamics/joints/b2DistanceJoint.js'></script>
        <script src='js/box2d/dynamics/joints/b2DistanceJointDef.js'></script>
        <script src='js/box2d/dynamics/joints/b2Jacobian.js'></script>
        <script src='js/box2d/dynamics/joints/b2GearJoint.js'></script>
        <script src='js/box2d/dynamics/joints/b2GearJointDef.js'></script>
        <script src='js/box2d/dynamics/joints/b2MouseJoint.js'></script>
        <script src='js/box2d/dynamics/joints/b2MouseJointDef.js'></script>
        <script src='js/box2d/dynamics/joints/b2PrismaticJoint.js'></script>
        <script src='js/box2d/dynamics/joints/b2PrismaticJointDef.js'></script>
        <script src='js/box2d/dynamics/joints/b2PulleyJoint.js'></script>
        <script src='js/box2d/dynamics/joints/b2PulleyJointDef.js'></script>
        <script src='js/box2d/dynamics/joints/b2RevoluteJoint.js'></script>
        <script src='js/box2d/dynamics/joints/b2RevoluteJointDef.js'></script>
        <!-- box2djs -->

		<SCRIPT LANGUAGE="JavaScript">
		function run() {
			canvas.width = canvas.width; // reset
            //world.CleanBodyList();
            world = createWorld();
			var code = document.getElementById('code').value;
			eval(code);
		}
		</SCRIPT>
	</HEAD>
	<BODY>
		<!--canvas id="canvas" width="300" height="225" class="clear" style="border:1px dotted"></canvas-->
		<canvas id="canvas" width='500' height='300' style="top:0px; left:0px;"></canvas>

    <script src='demos/draw_world.js'></script>
    <script src='demos/demo_base.js'></script>
    <script src='demos/demos.js'></script>
    <script src='demos/top.js'></script>

		<SCRIPT LANGUAGE="JavaScript">
			var canvas = document.getElementById('canvas');
			var context = canvas.getContext('2d');
		</SCRIPT>
		<BR/>
		<TEXTAREA NAME="code" id="code" COLS=70 ROWS=20 style="top:300px; left:10px;">
	demos.top.createBall(world, 350, 100, 50, true);
	demos.top.createPoly(world, 100, 100, [[0, 0], [10, 30], [-10, 30]], true);
	demos.top.createPoly(world, 150, 150, [[0, 0], [10, 30], [-10, 30]], true);
	var pendulum = createBox(world, 150, 100, 20, 20, false);
	var jointDef = new b2RevoluteJointDef();
	jointDef.body1 = pendulum;
	jointDef.body2 = world.GetGroundBody();
	jointDef.anchorPoint = pendulum.GetCenterPosition();
	world.CreateJoint(jointDef);

	var seesaw = demos.top.createPoly(world, 300, 200, [[0, 0], [100, 30], [-100, 30]]);
	jointDef.body1 = seesaw;
	jointDef.anchorPoint = seesaw.GetCenterPosition();
	world.CreateJoint(jointDef);
/*
	var ground = world.m_groundBody;

	// Define crank.
	var sd = new b2BoxDef();
	sd.extents.Set(5, 25);
	sd.density = 1.0;

	var bd = new b2BodyDef();
	bd.AddShape(sd);
	
	var rjd = new b2RevoluteJointDef();

	var prevBody = ground;

	bd.position.Set(500/2, 210);
	var body = world.CreateBody(bd);

	rjd.anchorPoint.Set(500/2, 235);
	rjd.body1 = prevBody;
	rjd.body2 = body;
	rjd.motorSpeed = -1.0 * Math.PI;
	rjd.motorTorque = 500000000.0;
	rjd.enableMotor = true;
	world.CreateJoint(rjd);

	prevBody = body;

	// Define follower.
	sd.extents.Set(5, 45);
	bd.position.Set(500/2, 140);
	body = world.CreateBody(bd);

	rjd.anchorPoint.Set(500/2, 185);
	rjd.body1 = prevBody;
	rjd.body2 = body;
	rjd.enableMotor = false;
	world.CreateJoint(rjd);

	prevBody = body;

	// Define piston
	sd.extents.Set(20, 20);
	bd.position.Set(500/2, 95);
	body = world.CreateBody(bd);

	rjd.anchorPoint.Set(500/2, 95);
	rjd.body1 = prevBody;
	rjd.body2 = body;
	world.CreateJoint(rjd);

	var pjd = new b2PrismaticJointDef();
	pjd.anchorPoint.Set(500/2, 95);
	pjd.body1 = ground;
	pjd.body2 = body;
	pjd.axis.Set(0.0, 1.0);
	pjd.motorSpeed = 0.0; // joint friction
	pjd.motorForce = 100000.0;
	pjd.enableMotor = true;

	world.CreateJoint(pjd);

	// Create a payload
	sd.density = 2.0;
	bd.position.Set(500/2, 10);
	world.CreateBody(bd);
*/
		</TEXTAREA>
		<INPUT id='button' TYPE="button" NAME="button" Value="Run" onClick="run()"/>
	</BODY>
</HTML>

